package String;

/**
 * @Classname JZ46数字翻译成为字符串
 * @Description TODO
 * @Date 2022/12/10 15:39
 * @Created by xjl
 */
public class JZ46数字翻译成为字符串 {

    public int translateNum(int num) {
        char[] nums = String.valueOf(num).toCharArray();
        int index = 0;
        return next(nums, index);
    }

    private int next(char[] nums, int index) {
        if (index > nums.length-1) {
            return 1;
        }
        int one = next(nums, index + 1);
        int two = 0;
        if (index<nums.length-1&&((nums[index]-'0')*10+(nums[index+1]-'0'))>9&&((nums[index]-'0')*10+(nums[index+1]-'0'))<26){
            two=next(nums,index+2);
        }
        return one + two;
    }
}
